<template>
  <hips-view sub-header-fixed>
    <hips-nav-bar
      slot="header"
      title="相机相册类"
      :back-button="{
        showLeftArrow: true,
      }"
      @nav-bar-back-click="$router.back()"
    />
    <demo-block title="scanCode">
      <hips-button @click="scanCodeFuc">
        扫描二维码
      </hips-button>
    </demo-block>

    <demo-block title="captureImage">
      <hips-button @click="captureImageFuc">
        拍照
      </hips-button>
    </demo-block>

    <demo-block title="chooseImage">
      <hips-button @click="chooseImageFuc">
        选择照片
      </hips-button>
    </demo-block>

    <demo-block title="scanBusinessCard">
      <hips-button @click="scanBusinessCardFuc">
        识别名片
      </hips-button>
    </demo-block>
  </hips-view>
</template>

<script>
import BasicView from '@/mixin/basic-view';
import { Button } from '@hips/vue-ui';

import { Camera } from '@hips/plugin-vue-jssdk';

const { scanCode, captureImage, chooseImage, scanBusinessCard } = Camera;

export default {
  components: {
    [Button.name]: Button,
  },
  mixins: [ BasicView ],
  data() {
    return {};
  },
  methods: {
    scanCodeFuc() {
      scanCode()
        .then((res) => {
          console.log('res = ', res);
        })
        .catch((err) => {
          console.log('err = ', err);
        });
    },
    captureImageFuc() {
      captureImage({
        allowEdit: true,
        targetSharp: 2,
      })
        .then((res) => {
          console.log('res = ', res);
        })
        .catch((err) => {
          console.log('err = ', err);
        });
    },
    chooseImageFuc() {
      chooseImage()
        .then((res) => {
          console.log('res = ', res);
        })
        .catch((err) => {
          console.log('err = ', err);
        });
    },
    scanBusinessCardFuc() {
      scanBusinessCard('camera')
        .then((res) => {
          console.log('res = ', res);
        })
        .catch((err) => {
          console.log('err = ', err);
        });
    },
  },
};
</script>

<style lang="stylus"></style>
